import java.io.IOException;

public class Main {
	
	/** The port number to listen for connections on. */
	private static final int port = 1234;
	
	/** The server. */
	private static MonitoringServer server;
	
	public static void main(String[] args0) {
		
		// Try initializing the server
		try {
			server = new MonitoringServer(port);
		} catch (IOException e) {
			System.err.println("Error occured while initalizing the server.");
			e.printStackTrace();
			return;
		}
		
		// Add runtime hook to shutdown server safely when program shuts down
		Runtime.getRuntime().addShutdownHook(new Thread() {
			public void run() {
				server.stop();
				System.out.println("SHUTDOWN");
			}
		});
		
	}
}
